package com.alipay.config;

import org.springframework.context.annotation.Configuration;

import java.io.FileWriter;
import java.io.IOException;

@Configuration
public class AlipayConfig {

    //↓↓↓↓↓↓↓↓↓↓请在这里配置您的基本信息↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

    // 应用ID,您的APPID，收款账号既是您的APPID对应支付宝账号
    public static String app_id = "2016102100730058";

    // 商户私钥，您的PKCS8格式RSA2私钥
    public static String merchant_private_key = "MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCADUOQovnmT45LULHsVCy1uFndvNBUKdXGzHt00KOB7dPqXvMH86SQZDpi+v2/kryD3+kH3RK2tusnNW+TxcDRTG0yNpedfXohmOMqJBnCzdnENWi+I3dK9WMG9HuzfQQaPzoPhay7v9bs4UxXRoAwrcUVKBG4OM1TqBVCRohjCUQb7/NOz267qNDHgNt2LMaUsBaRXif57iNo6GLpJ5t0CLs2+EXpyd5H5r1/l+hUj2Zv7OHe3crlVFKVoQel50hlSfXNLKGJX5jRGd6TjXS9lxQUcSSoZgrf8z1ODbnSISmPno6pR0uSLeV853S3zY7RGF+1ZPaLCK6fPBbyYRlpAgMBAAECggEAZ5/UPHjW+F0LDsHXqiMYJ1pvRvSkNmfAeudBRPAOUXfP1UtPKvEtDDg/05e/vscVTTbm0plBqqDuPUWN7KzMc9OATnFFUoqXShb6RkD+o9mHz7NU9wGmaP+ZSqiQbljN+BuQdb08YpdFa16LM9l2pW4KHivV4xn8dyV/RqnjdxiDnoCc+3ZFnGvzchVQH88joiERei0edkprD1uXUttz+rvSYKfwnILNfZ117zvH8oYJVN1dEzBQxI8/Fo5Tf3Euc+idrfq3Tmi4bOOf+GH2yE6pMCZkpoVYdzP3U6ftl6RPRc4ecDVg0ZCRqUM6Cuspm/MjPinuzpzT0HCaxXjSLQKBgQDDmW2WYkMy0iWfFgGwQ+CoXbZBYzOBofol+13EPw65v4XT2FEMgzW7YURaYFDbXRju8kkvkHTN2UBgRES0GCMtaxq/K30tcd/c4QyJD2XCnRpR2Kcn+CAmUIBEmEfobboLiprbe0BrJOzuj8AeTYFEoKmBVXhUlRWe3uE6cItCWwKBgQCnmA0PSAXnL28HDSwdRlotTD6/7kJRfNxk1T8X3kc1CZ3+DKy7BJpfcGvamgFi8ZfcU8pyrc3jMcHmHblmfcBojTRz41/F1iGvhkhYRbzIIcOstL77gt2Na7GEajlezSAEFWP83gF3KOlFdmZ7oDlp5uyE9nQaQu6nBMaQsaTWiwKBgGwqorGxMVwfXnK1ZsWlI8231Rwf0dH0UzNB6L6n6GrMASP/0gJLZSF0Tqpz7QMCXtF05wgIqK9VXwZdemjlmD57plTlpdnFyXiKc7Yv76RJ4M42M2olCxJlHinQ1KMyWtobEjwh0qPtzaC3mhSn476h4lsFev+7WjN7Ka55omlVAoGAWTjfqwUC74MXLr/afnNXysnOlkt3zv4ULzI/9qsFab0G+Zsx0havQKQPJz/aARzxZgDNxKO2+n8g5Stp6qCD8KVMCW5BLIfFQzbQCP6HdFxVWfqXujp/TKzKwt3yUQAPTV097/8Y9KE5Hxvbj3FLX4/q1xaF1P1RJGWseJe6U+UCgYBciBf+v9BhrinWIiDYyHxjITjsGjUxGby9vmHLBm0mt9hr2aUbItYo5GQiFv8M40oW/mkmzWYrrmlPru9Q3lxnVX051otuzJt+fFNa2m4Vkiv1NcRTk2PEFGLVDHq+xXWljc0uqcnh1rWCDO4Nw4LDhqQWjTgJ5jnoWc95e8cviQ==";

    // 支付宝公钥,查看地址：https://openhome.alipay.com/platform/keyManage.htm 对应APPID下的支付宝公钥。
    public static String alipay_public_key = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAxJgTxkju3hJr5ttIvPGkMinSzkafeOTwgjefni6sV4seQP3VyekcPod4pgHA7fdvpVEI/bbk97yN+ZDSjmf9PFfG4xvCW+r6rZ2gPcNeglRl3l/gDz8kZzGcu0l2NAXB2neD35ONXZkFVZD/L0LtE+q1vq4x77s/7DAmF/4oJ7EkHVx9qm6cd0RMhmtTIAgDzFjnMSVabznPQQtJAKOOls7flLee6G/mkBKvdRgXgtSV88OLnzrtVb6wgMAZmyPYmCJjkbO7/7hg0Wx8vg2ulaa5DZDbxqVHnhWtZAIOzr6zL3nUhNKaz8DoESoWgYs7tlTEmP3SBOMKii0FyqGx/wIDAQAB";

    // 服务器异步通知页面路径  需http://格式的完整路径，不能加?id=123这类自定义参数，必须外网可以正常访问
    public static String notify_url = "http://hv7p6g.natappfree.cc/alipay.trade.page.pay-JAVA-UTF-8/notify_url.jsp";

    // 页面跳转同步通知页面路径 需http://格式的完整路径，不能加?id=123这类自定义参数，必须外网可以正常访问
    public static String return_url = "http://hv7p6g.natappfree.cc/alipay.trade.page.pay-JAVA-UTF-8/return_url.jsp";

    // 签名方式
    public static String sign_type = "RSA2";

    // 字符编码格式
    public static String charset = "utf-8";

    // 支付宝网关
    public static String gatewayUrl = "https://openapi.alipaydev.com/gateway.do";

    // 支付宝网关
    public static String log_path = "D:\\logs\\alipay_logs";


    //↑↑↑↑↑↑↑↑↑↑请在这里配置您的基本信息↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑

    /**
     * 写日志，方便测试（看网站需求，也可以改成把记录存入数据库）
     *
     * @param sWord 要写入日志里的文本内容
     */
    public static void logResult(String sWord) {
        FileWriter writer = null;
        try {
            writer = new FileWriter(log_path + "alipay_log_" + System.currentTimeMillis() + ".txt");
            writer.write(sWord);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (writer != null) {
                try {
                    writer.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}

